import React from 'react';
import { Switch } from 'antd';

export default function WSwitch(props: any) {
  const { onSave, onChange, value, ...res } = props;

  function handle(value: boolean) {
    onChange?.(value);
    onSave();
  }

  return (
    <Switch
      {...res}
      checked={value}
      onChange={handle}
      checkedChildren="可选"
      unCheckedChildren="必选"
    />
  );
}
